package com.atguigu.paymentdemo.task;

import com.atguigu.paymentdemo.service.AliPayService;
import com.atguigu.paymentdemo.service.OrderInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Slf4j
@Component
public class AliPayTask {

    @Resource
    private OrderInfoService orderInfoService;

    @Resource
    private AliPayService aliPayService;

    /**
     * 从第0秒开始每隔30秒执行1次，查询创建超过5分钟，并且未支付的订单
     */
//    @Scheduled(cron = "0/30 * * * * ?")
//    public void orderConfirm(){
//
//        log.info("orderConfirm 被执行......");
//
//        List<OrderInfo> orderInfoList = orderInfoService.getNoPayOrderByDuration(1, PayType.ALIPAY.getType());
//
//        for (OrderInfo orderInfo : orderInfoList) {
//            String orderNo = orderInfo.getOrderNo();
//            log.warn("超时订单 ===> {}", orderNo);
//
//            //核实订单状态：调用支付宝查单接口
//            aliPayService.checkOrderStatus(orderNo);
//        }
//    }
}
